<template>
  <div>{{ data }}</div>
</template>

<script>
import { queryAnalysis } from '@/api/portal/manager/analysis'
export default {
  name: 'Statistics',
  props: {
    ids: Number,
    column: String
  },
  data() {
    return {
      data: null
    }
  },
  watch: {
    ids: {
      handler(newData, oldData) {
        this.initData()
      },
      immediate: true, // 父组件第一次传值时，执行handler，false则第一次不执行
      deep: false // formType为对象时，设置为true，此属性监听对象发生变化
    }
  },
  methods: {
    initData() {
      queryAnalysis({ id: this.ids }).then(res => {
        const { data } = res
        if (undefined !== data && data !== null && undefined !== data.data && data.data !== null) {
          this.data = data.data[0][this.column]
        } else {
          this.data = 0
        }
      })
    }
  }
}
</script>

<style scoped>

</style>
